<?php
class Activity {
	
	public static function log($action, $message = '', $params = '', $time = 0) {
		$log = new YumActivityLog();
		$log->user_id = intval(Yii::app()->user->id);
		$log->action = $action;
		$log->message = $message;
		$log->params = $params;
		$log->from 	= $_SERVER['SERVER_NAME'];
		$log->ip_address = Yii::app()->request->userHostAddress;
		$log->timestamp = $time == 0 ? time() : $time;
		
		return $log->save();
	}
	
	public static function referer_log($user_id, $action, $message = '', $params = '', $time = 0) {
		$log = new UserActivityLog();
		$log->user_id = $user_id;
		$log->action = $action;
		$log->from 	= $_SERVER['SERVER_NAME'];
		$log->message = $message;
		$log->params = $params;
		$log->ip_address = Yii::app()->request->userHostAddress;
		$log->timestamp = $time == 0 ? time() : $time;
		
		return $log->save();
	}
	
	public static function likevn_log($action, $message = '', $params = '', $time = 0) {
		$log = new UserActivityLog();
		$log->user_id = intval(Yii::app()->user->id);
		$log->action = $action;
		$log->message = $message;
		$log->params = $params;
		$log->from 	= $_SERVER['SERVER_NAME'];
		$log->ip_address = Yii::app()->request->userHostAddress;
		$log->timestamp = $time == 0 ? time() : $time;
	
		return $log->save();
	}
			
}